/*定义点类(二维,即包含x,y坐标) Point
定义一个图形类Figure：包含方法画图(onDraw)
定义一个三角形继承于图形类,
属性：三个点
方法：设置点，获取点等相关方法以及重写的画图方法
注：画图方法中要求打印出 画出的是一个什么图形和各个点坐标
定义一个圆形类，和三角形要求一致
定义一个画家类Painter
void draw(Figure* f);
方法：画画：可以画出一个图形
测试画家画画，画一个三角形，一个圆形 */
#include <iostream>
using namespace std;

class Point
{
private:
    int x;
    int y;
public:
    Point(int x,int y)
    :x(x),y(y){}
    ~Point(){}
    int getX()
    {
        return x;
    }
    int getY()
    {
        return y;
    }
    void setPoint(int a,int b)
    {
        x=a;
        y=b;
    }
    void display()
    {
        cout<<"("<<x<<","<<y<<")"<<endl;
    }
};

class Figure
{
private:
    
public:
    Figure(){}
    ~Figure(){}
    virtual void onDraw()=0;
};

class Triangle:public Figure
{
private:
    Point onePoint;
    Point twoPoint;
    Point thrPoint;
public:
    Triangle(Point a,Point b,Point c)
    :onePoint(a),twoPoint(b),thrPoint(c){}
    ~Triangle();
    Point getOne()
    {
        return onePoint;
    }
    Point getTwo()
    {
        return twoPoint;
    }
    Point getThr()
    {
        return thrPoint;
    }
    void setOne(int a,int b)
    {
        onePoint.setPoint(a,b);
    }
    void setTwo(int a,int b)
    {
        twoPoint.setPoint(a,b);
    }
    void setThr(int a,int b)
    {
        thrPoint.setPoint(a,b);
    }
    void onDraw()
    {
        cout<<"this is a triangle!"<<endl;
        cout<<"onePoint:";
        onePoint.display();
        cout<<"twoPoint:";
        twoPoint.display();
        cout<<"thrPoint:";
        thrPoint.display();
    }
};


class Circle:public Figure
{
private:
    Point center;
    int radius;
public:
    Circle(int x,int y,int radius)
    :center(x,y),radius(radius){}
    ~Circle(){}
    Point getCenter()
    {
        return center;
    }
    int getRadius()
    {
        return radius;
    }
    void setCenter()
    {
        int a,b;
        cout<<"please input x y:"<<endl;
        center.setPoint(a,b);
    }
    void setRadius()
    {
        cout<<"please input radius:"<<endl;
        cin>>radius;
    }
    void onDraw()
    {
        cout<<"this is a circle!"<<endl;
        cout<<"center:"<<"("<<center.getX()<<","<<center.getY()<<")"<<endl;
        cout<<"radius:"<<radius<<endl;
    }
};

class Painter
{
private:
    
public:
    Painter(){}
    ~Painter(){}
    void draw(Figure* f)
    {
        f->onDraw();
    }

};


int main(int argc,char*argv[])
{
    Figure *t1 = new Triangle(Point(1,1),Point(2,3),Point(4,5));
    t1->onDraw();

    Figure *c1 = new Circle(1,2,3);
    c1->onDraw();

    Painter p1;
    p1.draw(t1);
    p1.draw(c1);

    delete(t1);
    delete(c1);

    return 0;
}